<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*"%>
<%@ page import="xml.response.*"%>
<%@ page import="requestInterFace.Handle.*"%>
<%@ page import="xml.root"%>
<%@ page import="util.print.printLogCat"%>
<%@ page import="org.sql.table.*"%>
<%@ page import="xml.var"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="jqgrid.jqgrid"%>
<%@ page import="util.check"%>
<%@ include file="../../util/paramPrint.jsp" %>
<%@ page trimDirectiveWhitespaces="true" %> 
<%   

    /*********** jqgrid ******************/
		jqgrid jq=new jqgrid();
		jq.setRows(request.getParameter(jqgrid._rows));
		jq.setSord(request.getParameter(jqgrid._sord));
		jq.setSortname(request.getParameter(jqgrid._sortname));
		jq.setPage(request.getParameter(jqgrid._page));
		jq.setOper(request.getParameter(jqgrid._oper));
		jq.setSearch(request.getParameter(jqgrid._search));
		/*************************************/
		
		String userID=(String)session.getAttribute("User_ID");
		String userType=(String)session.getAttribute("User_Type");
		
		String Order_Products = request.getParameter("Order_Products");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		String User_ID = request.getParameter("User_ID");
		String UP_ID = request.getParameter("UP_ID");
		String Grop = request.getParameter("Grop");
		if(!check.checkString(Grop)){
		//如果grop没哟默认为 Order_Products
		Grop="Order_Products";
		}
		if(UP_ID!=null&&(!UP_ID.equals(""))){
			UP_ID=java.net.URLDecoder.decode(UP_ID,"UTF-8");
			}
			if(User_ID!=null&&(!User_ID.equals(""))){
			User_ID=java.net.URLDecoder.decode(User_ID,"UTF-8");
			}
		root root=new root();
		orderStat orderStat=new orderStat();
		orderinfo1_1 user=new orderinfo1_1();
		user.setResultField("Order_Products").setResultField("User_ID").setResultField("Product_Type");
		user=orderStat.StatProductSaleNum(user,Order_Products,startTime,endTime,User_ID,UP_ID,"",Grop);
		user.setLimit((jq.getPageInt()-1)*jq.getRowsInt(), jq.getRowsInt());
		if(jq.getSortname()!=null&&!jq.getSortname().equals("")){
		user.setOrder(jq.getSortname(),jq.getSord());
		}
		user.setResultField("Order_Products");
		
		Vector d=user.getTableFactroy();
		root.setRecords(""+d.size());//设置当前查询到的记录数
		int pageNum=user.getCount()/jq.getRowsInt();
		if((user.getCount()%jq.getRowsInt())>0){
			pageNum++;
		}
		root.setTotal_Count(""+pageNum);//查询到的总记录数数
		root.setLimit_Offset(""+jq.getPage());//当前查询页面
		for(int i=0;i<d.size();i++){
			orderinfo1_1 u=(orderinfo1_1)d.elementAt(i);
		Enumeration e=u.getTable().elements();
		response res=new response();
		res.setAttribute_Id(""+i);
	for(int j=0;j<u.getResultFieldNum();j++){
			String field=(String)u.getSql().getResultField().elementAt(j);
    		var v=(var)u.getTable().get(field);
			
	 	if(v.getName().equals("Order_Products")){
			//通过产品ID获取产品名称
			res.put(v.getName(), v);
			var name=new var();
			productHandle handle=new productHandle();
			name.setTag_this("cell");
			name.setName("Product_Name");
			name.setValue(handle.getProductName(v.getValue()));
			res.put(name.getName(),name);
			}else{
			res.put(v.getName(), v);
			}
		}
		root.addResponse(res);
		}
		//printLogCat.printlnWriter(root.getXmlString());
		String rep=root.getXmlString();
%>
<%=rep%>




